<%@page import="com.util.Config"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
	<base href="<%= basePath %>">
	<%= Config.htmlMeta %>
    <link rel="stylesheet" href="css/pintuer.css">
    <link rel="stylesheet" href="css/admin.css">
    <script type="text/javascript" src="js/luck/luck.js"></script>
    <link rel="stylesheet" href="js/luck/skin/default/luck.css">
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/pintuer.js"></script>
    <script type="text/javascript" src="js/respond.js"></script>
    <script type="text/javascript" src="js/admin.js"></script>
    <script type="text/javascript" src="js/js.js"></script>
    <link type="image/x-icon" href="/favicon.ico" rel="shortcut icon" />
    <link href="/favicon.ico" rel="bookmark icon" />
    <style type="text/css">
    	.ben a:hover{color:#CC3300;text-decoration:underline;}
    </style>
    <script type="text/javascript">
    	var yzbz = "";
	    window.onload = function init(){
	        var passwordValue = getCookieValue("password");
	    	var yhxhValue = getCookieValue("yhxh");
	    	if(yhxhValue.length > 0 && passwordValue.length > 0){
	    		 $("#yhxh").val(yhxhValue);  
	 	         $("#password").val(passwordValue); 
	 	         document.getElementById("saveMe").checked = true;
	    	}
	    };
	    //写入点击事件  
        function login(){
	    	if(checkForm()){
	    		$("#LoginButton").attr("class", "button button-block bg-main icon-refresh");
		    	$("#LoginButton").html("登陆中");
		    	var yhxhValue = $("#yhxh").val();
	            var passwordValue = $("#password").val();
	            //Ajax进行登录
	            $.ajax({
	            	url: '<%=path %>/user/login.action',
	            	type: 'POST',
	            	dataType : 'text',
	            	data: $("#form1").serialize(),
	            	success: function(msg){
	            	    if(msg == "1"){
	                        if(document.getElementById("saveMe").checked){
	                            setCookie("yhxh",$("#yhxh").val(),24,"/");  
	                            setCookie("password",$("#password").val(),24,"/");  
	                        } else {
	                        	var yhxh = getCookieValue("yhxh") + "";
	                        	if(yhxh.length > 0){
		                        	deleteCookie("yhxh");
		                        	deleteCookie("password");
	                        	}
	                        }
	                        luckA('200px', '登录成功,正在跳转请稍候...', 6);
	                        window.location.href = "index.html"; 
	            	    } else {
	            	    	luckA('200px', '账号或密码错误,请检查!', 5);
	            	    	$("#LoginButton").attr("class", "button button-block bg-main text-big");
	        		    	$("#LoginButton").html("立即登录后台");
	            	    }
	            	},
	            	error: function(msg){
	            		luckA('200px', '系统出现故障,请刷新页面重新登录!', 5);
	            		$("#LoginButton").attr("class", "button button-block bg-main text-big");
        		    	$("#LoginButton").html("立即登录后台");
	            	}
	            });
	    	}
        }
	    function checkForm(){
	    	if(document.getElementById("yhxh").value == ""){
	    		luckA('200px', '登录账号不能为空', 5);
	    		return false;
	    	} else if(document.getElementById("password").value == ""){
	    		luckA('200px', '密码不能为空', 5);
	    		return false;
	    	} else if(document.getElementById("passcode").value == ""){
	    		luckA('200px', '验证码不能为空', 5);
	    		return false;
	    	} else {
	    		return true;
	    	}
	    }
    </script>
</head> 
<body>
<div class="container">
    <div class="line">
        <div class="xs6 xm4 xs3-move xm4-move">
            <br /><br />
            <div class="media media-y">
                <a href="#"><img src="images/logo.png" class="radius"/></a>
            </div>
            <br /><br />
            <form action="" id="form1" name="form1" method="post">
	            <div class="panel" style="width: 400px;margin-left: auto;margin-right: auto;" >
	                <div class="panel-head"><strong><%= Config.OAName %></strong></div>
	                <div class="panel-body" style="padding:30px;">
	                    <div class="form-group">
	                        <div class="field field-icon-right">
	                            <input type="text" class="input" name="yhxh" onkeydown="if(event.keyCode==13) $('#password').focus();" maxlength="8" id="yhxh" placeholder="登录账号" data-validate="required:请填写账号" />
	                            <span class="icon icon-user"></span>
	                        </div>
	                    </div>
	                    <div style="margin-top: 8px"></div>
	                    <div class="form-group">
	                        <div class="field field-icon-right">
	                            <input type="password" class="input" name="password" onkeydown="if(event.keyCode==13) $('#passcode').focus();" id="password" placeholder="登录密码" data-validate="required:请填写密码" />
	                            <span class="icon icon-key"></span>
	                        </div>
	                    </div>
	                    <div style="margin-top: 8px"></div>
	                    <div class="form-group">
	                        <div class="field">
	                            <input type="text" onkeydown="chknum(this);" onblur="chkPasscode(this);" class="input" maxlength="4" name="passcode" id="passcode" placeholder="填写右侧的验证码" />
	                            <img style="cursor:pointer;" onclick="javascript:refresh(this);" src="./code3.jsp" id="code_img" title="点击更换" align="AbsMiddle" width="80" height="32" class="passcode" />
	                        </div>
	                    </div>
	                    <div style="margin-top: 3px"></div>
	                    <div class="form-group">
	                    	<div class="field" align="right">
	                    		<span>
	                    			<input type="checkbox" id="saveMe" style="vertical-align:text-bottom; margin-bottom:2px; *margin-bottom:-2px;" name="saveMe"/>&nbsp;记住密码
	                    		</span>
	                    	</div>
	                    </div>
	                    <div class="form-group">
	                    	<div class="field" align="right">
	                    		&nbsp;<a href="#" onclick="wjmm();" style="text-decoration:none;font-size: 11px;">忘记密码?</a> 
	                    		&nbsp;<a href="#" onclick="zcxzh();" style="text-decoration:none;font-size: 11px;">注册新帐号 </a>
								&nbsp;<a href="#" onclick="yjfk();" style="text-decoration:none;font-size: 11px;">意见反馈</a>
	                    	</div>
	                    </div>
	                </div>
	                <div class="panel-foot text-center" style="margin-top: -15px;">
	                	<button id="LoginButton" type="button" onclick="login()" class="button button-block bg-main text-big">立即登录后台</button>
	                </div>
	            </div>
            </form>
        </div>
    </div>
</div>
</body>
</html>
